﻿using ERP.SYS.Model.Entity;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;

namespace ERP.SYS.Config;

public class ERPSysDbContext : DbContext
{
    private readonly ILogger<ERPSysDbContext> _logger;
    public ERPSysDbContext(DbContextOptions<ERPSysDbContext> options, ILogger<ERPSysDbContext> logger) : base(options)
    {
        _logger = logger;
    }

    protected ERPSysDbContext()
    {
    }

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {   
        modelBuilder.Entity<SysRoleMenu>().HasNoKey();
        modelBuilder.Entity<SysRoleUser>().HasNoKey();
        modelBuilder.Entity<SysRolePermission>().HasNoKey();
    }

    public virtual DbSet<SysMenu> SysMenus { get; set; }

    public virtual DbSet<SysPermission> SysPermissions { get; set; }

    public virtual DbSet<SysRole> SysRoles { get; set; }

    public virtual DbSet<SysRoleMenu> SysRoleMenus { get; set; }

    public virtual DbSet<SysRolePermission> SysRolePermissions { get; set; }

    public virtual DbSet<SysRoleUser> SysRoleUsers { get; set; }

    public virtual DbSet<SysUser> SysUsers { get; set; }
}
